/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.res0w.SMMS.ds;

import com.res0w.SMMS.factory.DataBaseOperate;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author res0w
 * @since 2009-9-22
 * @version 0.2
 *
 */
public class SettingSchedule implements BatchSqlInterface {

    public ArrayList scheduleList = new ArrayList();
    public int itemsPriority;
    public String itemsName;
    public String itemsDate;
    public String itemsLocation;
    public int isFinished;

    public SettingSchedule() {
        itemsPriority = 0;
        itemsName = null;
        itemsDate = null;
        itemsLocation = null;
        isFinished = 0;
    }

    public String[] exeSqls() {
         String[] sqls = new String[1];
        sqls[0] = "insert into setting_schedule values('" + itemsPriority + "'," +
                "'" + itemsName + "','" + itemsDate + "','" + itemsLocation + "'," +
                "'" + isFinished + "')";
        return sqls;
    }

    public void readSqls() {
//        throw new UnsupportedOperationException("Not supported yet.");
        try {
            DataBaseOperate db=new DataBaseOperate();
            ResultSet rs = null;
            String sql = null;
            sql = "select * from setting_schedule";
            rs = db.dbQueryMuti(sql);
            while (rs.next()) {
                itemsPriority = Integer.parseInt(rs.getString(1));
                itemsName = rs.getString(2);
                itemsDate = rs.getString(3);
                itemsLocation = rs.getString(4);
                isFinished = Integer.parseInt(rs.getString(5));
                //写入arrayList;
                scheduleList.add(itemsPriority);
                scheduleList.add(itemsName);
                scheduleList.add(itemsDate);
                scheduleList.add(itemsLocation);
                scheduleList.add(isFinished);

            }
            db.dbClosed();
        } catch (SQLException ex) {
            Logger.getLogger(SettingSchedule.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
